let vm = new Vue({
    el:'#app',  //选中整个main
    data:{
       user:{
           username:'',
           password:'',
           email:''
       },
        checkPassword:'',
        checkUserFlag:true,     //用户是否已经存在
    },
    methods:{
        //注册
        register:function () {
            if (this.user.username===''||this.user.username===undefined||this.user.username.length<=0){
                layer.msg("用户名不能为空")
            }else if (this.user.password===''||this.user.password===undefined||this.user.password.length<=0){
                layer.msg("密码不能为空")
            }else if (this.user.email===''||this.user.username===undefined||this.user.email.length<=0){
                layer.msg("邮箱不能为空")
            }else {
                axios.post("user/register",this.user).then(result=>{
                    if (result.data.success) {
                        layer.msg(result.data.msg);
                        location.href = "index.html";
                    }else {
                        layer.msg(result.data.msg);
                    }
                }).catch(error=>{
                    layer.msg(error.message)
                })
            }
        }
    }
});